function loadCharts(name) {
	// reset charts
	$("#atmosphere").empty();
	$("#temperature").empty();
	$("#distance-from-sun").empty();
	
	loadAtmosphere(name);
	loadTemperature(name);
	loadDistanceFromSun(name);
	
	if(name === "earth") {
		loadPopulation();
	}
}

function loadAtmosphere(name) {
	if(name === "mercury") {
		var options = {
			title: 'Exosphere'
		};			
	}
	else {
		var options = {
			title: 'Atmosphere'
		};			
	}
	
	var chart = new google.visualization.PieChart(document.getElementById('atmosphere'));
	var data = new google.visualization.DataTable(planetData[name].atmosphere);
	chart.draw(data, options);
}

function loadTemperature(name) {
	var options = {
		title: 'Temperature'
	};	
			
	var chart = new google.visualization.LineChart(document.getElementById('temperature'));
	//var data = new google.visualization.DataTable(planetData[name].temperature);
    var data = google.visualization.arrayToDataTable([
      ['Time', 'Mercury', 'Venus', 'Earth'],
      ['Day',  350, 480, 60],
      ['Night',  -170, 480, -90]
    ]);	
	chart.draw(data, options);	
}

function loadDistanceFromSun(name) {
	var options = {
		title: 'Distance From Sun',
		hAxis: {title: "Planet", titleTextStyle: {color: 'red'}}
	};		
	
	var chart = new google.visualization.ColumnChart(document.getElementById('distance-from-sun'));
	var data = new google.visualization.DataTable(planetData[name].distanceFromSun);
	chart.draw(data, options);	
}

function loadPopulation() {
	$("#population").show();
	
	var options = {
		title: 'Population'
	};
	
    var data = google.visualization.arrayToDataTable([
      ['Country', 'Population'],
      ['China', 500]
    ]);		
	
	var chart = new google.visualization.GeoChart(document.getElementById('population'));	
	chart.draw(data, options);
}
